﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace EasyFramework.IO
{
    public class FileHelper
    {
        [DllImport("kernel32.dll ", CharSet = CharSet.Auto)]
        public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);

        /// <summary>
        /// 获取在DOS下的长文件路径对应的短文件路径<para />
        /// 2011-12-13
        /// </summary>
        /// <param name="longPath">长文件路径</param>
        /// <returns></returns>
        public static string GetShortPathName(string longPath)
        {
            StringBuilder shortPath = new StringBuilder(80);
            int result = GetShortPathName(longPath, shortPath, shortPath.Capacity);
            return shortPath.ToString();
        }

    }
}
